/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package riviere;

import java.util.ArrayList;
import java.util.List;

public class Riviere implements Mesurable {

	private List<Segment> segments;

	public Riviere() {
		segments = new ArrayList<Segment>();
	}

	public Riviere(List<Segment> segments) {
		this.segments = segments;
	}

	public boolean ajouterSegment(Segment s) {
		return segments.add(s);
	}

	public void supprimerSegment(Segment s) {
		segments.remove(s);
	}

	@Override
	public double calculerLongueur() {
		double longueur = 0;
		if (segments != null && segments.size() > 0) {
			for (Segment s : segments) {
				longueur = longueur + s.calculerLongueur();
			}
		}

		return longueur;
	}

	public List<Segment> getSegments() {
		return segments;
	}

}
